package com.usc.huangjiapeng;

import java.security.MessageDigest;
import java.util.UUID;

import sun.misc.BASE64Encoder;

public class IdUtil {
	/*
	 * UUID
	 */
	public static String genUUId() {
		return UUID.randomUUID().toString();
	}

	/*
	 * Md5加密
	 */
	public static String genMd5(String str) {
		try {
			// 确定计算方法
			MessageDigest md5 = MessageDigest.getInstance("MD5");
			BASE64Encoder base64en = new BASE64Encoder();
			// 加密后的字符串
			String newstr = base64en.encode(md5.digest(str.getBytes("utf-8")));
			return newstr;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}

